package com;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

import com.gargoylesoftware.htmlunit.BrowserVersion;
import com.gargoylesoftware.htmlunit.NicelyResynchronizingAjaxController;
import com.gargoylesoftware.htmlunit.WebClient;
import com.gargoylesoftware.htmlunit.html.HtmlPage;

public class PreloadListener<ServeltContextEvent> implements ServletContextListener {
	public static HtmlPage rootPage = null;
	public static Map loginInfo = new HashMap();

	public void contextDestroyed(ServletContextEvent sce) {
	}

	public void contextInitialized(ServletContextEvent sce) {
		WebClient webClient = new WebClient(BrowserVersion.CHROME);

		webClient.getOptions().setJavaScriptEnabled(true);
		webClient.getOptions().setCssEnabled(false);
		webClient.getOptions().setActiveXNative(false);
		webClient.getOptions().setAppletEnabled(false);
		webClient.getOptions().setActiveXNative(false);
		webClient.getOptions().setGeolocationEnabled(false);
		webClient.getOptions().setDoNotTrackEnabled(false);
		webClient.getOptions().setHomePage("null");
		webClient.getOptions().setThrowExceptionOnScriptError(false);
		webClient.setAjaxController(new NicelyResynchronizingAjaxController());
		try {
			rootPage = (HtmlPage) webClient
					.getPage("http://erp.kanq.com.cn:806/cops/login/index.html");
		} catch (Exception localException) {
		}
		System.out.println("ERP页面打开成功！");
	}
}